package com.ahcloud.enhance.lock.examples;

import com.ahcloud.enhance.lock.base.LockUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.imps.CuratorFrameworkImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: distributedlock-enhance
 * @description:
 * @author: YuKai Fan
 * @create: 2024/5/1 00:24
 **/
@RestController
@RequestMapping("/exam")
public class LockController {

    @GetMapping("/getLock")
    public boolean getLock(String key) {
        return LockUtils.tryLock(key);
    }

    @GetMapping("/getLockClient")
    public String getLockClient() {
        return LockUtils.getLockClient().getClass().getName();
    }

}
